<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增离职申请')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-quit-add">
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>部门：</label>
            <div class="col-sm-8">
                <select name="deptId" class="form-control m-b" th:with="deptAll=${@deptService.getDeptAll()}" disabled="disabled">
                    <option value="">请选择</option>
                    <option th:each="dept : ${deptAll}" th:text="${dept.getShowName()}" th:value="${dept.getDeptId()}" th:selected="${dept.getDeptId() == hrEmp?.deptId}" th:hidden="${dept.getStatus() == '1' || dept.getDelFlag() != '0' }"></option>
                </select>
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>岗位：</label>
            <div class="col-sm-8">
                <select name="postId" class="form-control m-b" th:with="postAll=${@postService.getPostAll()}" disabled="disabled">
                    <option value="">请选择</option>
                    <option th:each="post : ${postAll}" th:text="${post.getPostName()}" th:value="${post.getPostId()}" th:selected="${post.getPostId() == hrEmp?.postId}" th:hidden="${post.getStatus() == '1'}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>职级：</label>
            <div class="col-sm-8">
                <select name="rank" class="form-control m-b" th:with="rank=${@dict.getType('employeesGrade')}" required>
                    <option value="">请选择</option>
                    <option th:each="dict : ${rank}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>预计离职时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="quitTime" class="form-control" placeholder="yyyy-MM-dd" readonly="readonly" type="text" required>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>离职原因：</label>
            <div class="col-sm-8">
                <textarea name="reason" class="form-control" required></textarea>
                <input name="title" id="title" class="form-control" type="text" style="display: none;">
            </div>
        </div>
        <div th:replace="include/fileUploadUtil::fileUploadUtil('上传附件',5)" ></div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script type="text/javascript">
    var prefix = ctx + "hr/quit"
    $("#form-quit-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {

            //上传图片
            $("#testListAction").click();
            if (!$("#demoList").html()){
                //没有图片直接提交表单
                submitFrom();
            }

        }
    }

    function submitFrom(){
        $('input[name="title"]').val('[[${hrEmp?.empName}]]离职申请');
        //提交时设置disabled失效 否则表单不会提交该字段
        $("select[name=deptId]").attr("disabled",false);
        $("select[name=postId]").attr("disabled",false);
        $.operate.save(prefix + "/add", $('#form-quit-add').serialize());
    }


    $("input[name='quitTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        startDate: new Date(),
        autoclose: true
    });

    $("input[name='realityStartTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        minDate: new Date(),//过期时间不可选择
        autoclose: true
    });

    $("input[name='realityEndTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        minDate: new Date(),//过期时间不可选择
        autoclose: true
    });

    $("input[name='applyTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        minDate: new Date(),//过期时间不可选择
        autoclose: true
    });
</script>
</body>
</html>